Skip to content

chore: add test:changed for running only affected tests - #6158

Merged
evanpelle merged 2 commits into
openfrontio:mainfrom
wraith4081:chore/test-changed
Oct 26, 2026
Merged

evanpelle merged 2 commits into
openfrontio:mainfrom
wraith4081:chore/test-changed

Conversation

@wraith4081

Copy link
Copy Markdown
Member

Description:

Adds npm run test:changed, which is vitest run --changed origin/main. It runs only the tests that import something changed on the branch, plus staged, unstaged and new files. Vitest compares against the merge base, so a stale origin/main doesn't pull in tests for upstream commits you don't have.

CLAUDE.md now lists it and asks agents to use it, or the files they touched, while working, and leave the full suite to CI. Most of the full run goes to a few long simulation tests (NationGoldPerMinute, NationsWorld, TradeTrainScenarios, FullGameSnapshot, NationExecutions). Those 30 tests take about half the suite's test time, and they only matter when the engine changes. When it does, they still get picked.

Measured locally on main (8 cores / 16 threads):

test files time
npm test 673 126s / 130s
test:changed, one client file edited (NewsBox.ts) 5 4.2s
test:changed, one engine file edited (NationMIRVBehavior.ts) 37, sims included 69s

Heads-up:

  • It follows imports only. Tests that read files with fs (maps in tests/testdata/, resources/, snapshot files) aren't picked when only those files change. CLAUDE.md says to run those by name, and CI still runs everything.
  • Changing package.json or the vitest config makes it run the whole suite. That includes this PR's own branch. CLAUDE.md mentions this too, so nobody thinks it's broken.
  • Nothing changes for npm test or CI.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory

Please put your Discord username so you can be contacted if a bug or regression is found:

wraith4081

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 67c67be4-dbe3-4a82-8e15-4d5a5edf90fd
Commits

Reviewing files that changed from the base of the PR and between e5e31ad and 906dca5.

Files selected for processing: 2
  • CLAUDE.md
  • package.json

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

Adds npm run test:changed, which runs Vitest against changes relative to origin/main. The project guidance describes when to use this command, what it may miss, and which changes trigger the full suite.

Changes

Changed-test workflow

Layer / File(s) Summary
Add the changed-test workflow
package.json, CLAUDE.md
Adds the test:changed script and documents when to use it, its limits for tests that read files through fs, and full-suite triggers in package.json or Vitest configuration.

Priority: Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Possibly related PRs

  • openfrontio/OpenFrontIO#6155: Updates Vitest configuration, which the changed-test guidance identifies as a trigger for running the full suite.
  • openfrontio/OpenFrontIO#6133: Adds filesystem-based map tests, which the guidance notes may need to be run by name when map files change.

Suggested reviewers: evanpelle

Merge Risk: Minimal · previous review 906dc

The changed-test command and guidance are localized, with no identified merge-blocking impact.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: adding the test:changed command for affected tests.
Description check Passed The description accurately explains the new command, documentation updates, test-selection limits, performance measurements, and unchanged CI behavior.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (2 skipped: 2 unsupported.)

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A changed-test command joins the list
Vitest checks what changed since main
File reads can hide a test from view
Some config changes run the full suite
Clear guidance keeps the steps in view

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Claude Code Review

Verdict: looks good. Findings: 0 critical, 0 major, 0 minor.

No issues found. Checked for bugs and CLAUDE.md compliance.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Claude Code Review

Reviewed range: 906dca5..cea10a3

Verdict: looks good. Findings: 0 critical, 0 major, 0 minor.

All changes in this range came in with the merge of main (#6147, clan column hidden by default) and aren't part of this PR's own diff (CLAUDE.md, package.json). Those files haven't changed since the last review.

No issues found. Checked for bugs and CLAUDE.md compliance.

@wraith4081

Copy link
Copy Markdown
Member Author

/ready

@evanpelle evanpelle added this to the v36 milestone Oct 26, 2026

@evanpelle evanpelle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@evanpelle
evanpelle merged commit 6178a6d into openfrontio:main Oct 26, 2026
16 of 17 checks passed
@github-project-automation github-project-automation Bot moved this from Triage to Complete in OpenFront Release Management Oct 26, 2026

This branch was previously deployed

1 inactive deployment
backport — cea10a31 Deployed Oct 26, 2026 by evanpelle via Cherry-pick #623
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants